package meadow;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import uk.ac.nott.cs.g53dia.Bee;
import uk.ac.nott.cs.g53dia.Cell;
import utils.ControlPanel;
import valueobj.GlobalState;
import valueobj.SimulationSettings;

public class MeadowWrapper extends JFrame {
  private static MeadowWrapper INSTANCE;
  
  public static void initialize(String title, int w, int h, int columns, int rows, GlobalState state) {
    INSTANCE = new MeadowWrapper(title, w, h, columns, rows, state);
  }

  public static synchronized MeadowWrapper getInstance() {
    return INSTANCE;
  }
	
  private Meadow meadow;
  JLabel info;

	private MeadowWrapper(String title, int w, int h, int columns, int rows, GlobalState state) {
		setTitle(title);
		info = new JLabel("info");
		this.meadow = new Meadow(w, h, rows, columns, state, this);
		JPanel panel = new JPanel();
		panel.setLayout(new BorderLayout());
		panel.setPreferredSize(new Dimension(w, h));
		JScrollPane scrollPane = new JScrollPane(this.meadow);
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(info, BorderLayout.SOUTH);
    add(panel);
    Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
		pack();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//		toBack();
		setVisible(true);
	}
	
	

	
  public JLabel getInfo() {
    return info;
  }



  
  public void setInfo(JLabel info) {
    this.info = info;
  }



  public void updt(Bee bee, Cell[][] cells) {
		meadow.update(bee, cells);
	}

}
